<template>
  <div class="page-container" v-loading="loading" v-loadingCommonStyle>

    <ex_header_spiler :title="$tt('label_base_info')" />
    <ex_super_desc v-bind="baseOption" :data="form">
    </ex_super_desc>
    <ex_header_spiler :title="$tt('label_sku_list')" />
    <ex_super_table :model="tableModel" :data="form.detailList" size="default" />
  </div>
</template>

<script>
import router_params from '@/mixin/router_params';

let defaultObj = {

}
export default {
  title: 'label_halyk_order_detail',
  name: "label_halyk_order_detail",
  mixins: [router_params],
  components: {},

  data() {
    return {
      loading: false,
      form: _.cloneDeep(defaultObj),
      baseOption: {
        attrs: this.$defaultDetailDescAttrs,
        model: [
          { key: 'code', label: 'label_platform_code', 'width': 120, 'show-overflow-tooltip': true, },
          {
            key: 'customerName', label: 'label_customer_info', 'width': 120, 'show-overflow-tooltip': true,
            formatter: (r, c, v, i) => this.$formatNameCode(v, r.customerCode)
          },
          {
            key: 'totalPrice', label: '总价格', 'width': 110, 'show-overflow-tooltip': true,
            formatter: (r, c, v, i) => {
              return r.totalPrice + '[' + r.currencyType + '] '
            }
          },
          {
            key: 'deliveryCost', label: '运费', 'width': 110, 'show-overflow-tooltip': true,
            formatter: (r, c, v, i) => {
              return r.deliveryCost + '[' + r.currencyType + '] '
            }
          },
          {
            key: 'deliveryMode', label: '交货方式', 'width': 110, 'show-overflow-tooltip': true,
          },
          {
            key: 'deliveryType', label: '交货类型', 'width': 110, 'show-overflow-tooltip': true,
          },
          {
            key: 'state', label: '平台订单状态一', 'width': 110, 'show-overflow-tooltip': true,
          },
          {
            key: 'status', label: '平台订单状态二', 'width': 110, 'show-overflow-tooltip': true,
          },
          {
            key: 'paymentMode', label: '支付方式', 'width': 110, 'show-overflow-tooltip': true,
          },
          {
            key: 'deliveryAddressStreetName', label: '街道名', 'width': 110, 'show-overflow-tooltip': true,
          },
          {
            key: 'deliveryAddressStreetNumber', label: '街道号', 'width': 110, 'show-overflow-tooltip': true,
          },
          {
            key: 'deliveryAddressTown', label: '镇', 'width': 110, 'show-overflow-tooltip': true,
          },
          {
            key: 'deliveryAddressDistrict', label: '行政区', 'width': 110, 'show-overflow-tooltip': true,
          },
          {
            key: 'deliveryAddressBuilding', label: '建筑', 'width': 110, 'show-overflow-tooltip': true,
          },
          { key: 'deliveryAddressFormattedAddress', label: 'label_consignee_address', 'width': 110, 'show-overflow-tooltip': true, },

          {
            key: 'customerFirstName', label: '买家名称', 'width': 110, 'show-overflow-tooltip': true,
            formatter: (r, c, v, i) => {
              return r.customerFirstName + ' ' + r.customerLastName
            }
          },
          { key: 'customerCellPhone', label: '买家电话', 'width': 110, 'show-overflow-tooltip': true, },

          { key: 'providerType', label: '供应类型', 'width': 110, 'show-overflow-tooltip': true, },

          { key: 'endTime', label: '订单完结时间', formatter: (r, c, v, i) => this.$dateFormat(v) },
          {
            key: 'orderStatus', label: 'label_status', 'width': 120, 'show-overflow-tooltip': true,
            formatter: (r, c, v, i) => this.$enumShow(v, "SrmOrderStatusEnum")
          },
          { key: 'shipmentTrackingNumber', label: 'label_waybill_delivery_number', 'width': 110, 'show-overflow-tooltip': true, },
          {
            key: 'exceptionMsg', label: 'label_exception_info',
            render: (h, { data, item }) => {
              const code = data[item.key]
              if (!code) return ""
              return (<text_extra_tooltip_operate position_relative
                value={code} ellipsis
                data_type={item.key} data_id={data.id}
              />)
            },
          },
          { key: 'creationDate', label: 'label_create_time', formatter: (r, c, v, i) => this.$dateFormat(v) },

        ],
      },
      tableModel: [
        { key: 'code', label: 'label_platform_product_code', 'width': 120, 'show-overflow-tooltip': true, },
        { key: 'name', label: 'label_platform_product_name', 'width': 140, 'show-overflow-tooltip': true, },
        { key: 'manufacturer', label: '供应商', 'width': 120, 'show-overflow-tooltip': true, },

        {
          key: 'totalPrice', label: '总价格', 'width': 110, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => {
            return r.totalPrice + '[' + r.currencyType + '] '
          }
        },
        {
          key: 'deliveryCost', label: '运费', 'width': 110, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => {
            return r.deliveryCost + '[' + r.currencyType + '] '
          }
        },
        {
          key: 'basePrice', label: '产品价格', 'width': 110, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => {
            return r.deliveryCost + '[' + r.currencyType + '] '
          }
        },
        { key: 'quantity', label: 'label_count', 'min-width': 120, 'show-overflow-tooltip': true, },

        { key: 'skuBarcode', label: 'label_sku_code', 'width': 120, 'show-overflow-tooltip': true, },
        {
          key: 'skuOnlyCode', label: 'label_sku_only_code', 'width': 220,
        },
        { key: 'skuName', label: 'label_name', 'width': 120, 'show-overflow-tooltip': true, },

      ],
    };
  },

  methods: {

    init_data_default(into_params) {
      if (into_params.id) {
        this.loading = true
        this.$ajax({
          url: "/srm-api/platform/HalykOrderRpc/detail.json",
          method: 'post',
          data: { id: into_params.id },
          success: (res) => {
            this.form = Object.assign({}, _.cloneDeep(defaultObj), res.data)
            this.fixTabLabel()
          },
          complete: () => {
            this.loading = false

          }

        })
      }
      this.fixTabLabel()
    },
    fixTabLabel() {
      // if (!!this.form.code) {
      //   this.$emit("tagModifyLabel", { label: this.$formatNameCode(this.$tt("label_halyk_order_detail"), this.form.code || '') })
      // } else {
      //   this.$emit("tagModifyLabel", { label: this.$tt("label_halyk_order_detail") })
      // }
    },

  }
}
</script>



<style scoped></style>
